package com.sxu.generate;

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.sxu.entity.properties.PropertiesTrace;
import com.sxu.entity.properties.PropertiesCityPollutantForecast;
import com.sxu.entity.properties.PropertiesCityWeatherForecast;
import com.sxu.entity.properties.PropertiesSitePollutantForecast;
import com.sxu.entity.geometry.GeometryMultiPolygon;
import com.sxu.entity.geometry.GeometryPoint;
import com.sxu.entity.geo.CityPollutantForecast;
import com.sxu.entity.geo.CityWeatherForecast;
import com.sxu.entity.geo.SitePollutantForecast;
import com.sxu.entity.geo.Trace;

public class GenerateJson {

	public static JSONObject generateEachJSON(String sitename, String pollutant, String industry, int time, int company,
			Float value, Float[] coordinates) {
		// private String sitename;
		// private String pollutant;
		// private String industry;
		// private int time;
		// private int company;
		// private Float value;
		PropertiesTrace properties = new PropertiesTrace(sitename, pollutant, industry, time, company, value);
		// private String type;
		// private Float[] coordinates;
		GeometryPoint geometry = new GeometryPoint(coordinates);
		// private String type;
		// private Properties properties;
		// private Geometry geometry;
		Trace cd = new Trace(properties, geometry);
		return (JSONObject) JSONObject.toJSON(cd);
	}

	public static JSONObject generateEachAirQualityJSON(String pollutant, int time, Float value, Float[] coordinates) {
		// private String pollutant;
		// private int time;
		// private Float value;
		PropertiesCityPollutantForecast properties = new PropertiesCityPollutantForecast(pollutant, time, value);
		// private String type;
		// private Float[] coordinates;
		GeometryPoint geometry = new GeometryPoint(coordinates);
		// private String type;
		// private Properties properties;
		// private Geometry geometry;
		CityPollutantForecast aq = new CityPollutantForecast(properties, geometry);
		return (JSONObject) JSONObject.toJSON(aq);
	}

	public static JSONObject generateEachChangzhiForecastJSON(String time, Integer temp, Integer pressure, Integer rh,
			Integer windSpeed, String windDirect, Integer totalCloudCover) {
		// private String time;
		// private Integer temp;
		// private Integer pressure;
		// private Integer rh;
		// private Integer windSpeed;
		// private String windDirect;
		// private Integer totalCloudCover;
		PropertiesCityWeatherForecast properties = new PropertiesCityWeatherForecast(time, temp, pressure, rh, windSpeed, windDirect,
				totalCloudCover);
		// private final String type = "MultiPolygon";
		// private final Float[][][][] coordinates = {
		// { { { 112.7f, 36f }, { 113.3f, 36f }, { 113.3f, 36.5f }, { 112.7f,
		// 36.5f } } } };
		GeometryMultiPolygon geometry = new GeometryMultiPolygon();
		// private final String type = "Feature";
		// private PropertiesForecast properties;
		// private GeometryMultiPolygon geometry;
		CityWeatherForecast cf = new CityWeatherForecast(properties, geometry);
		return (JSONObject) JSONObject.toJSON(cf);
	}

	// 生成每个站点每个时刻对应污染物的单条json
	public static JSONObject generateSiteConditionJSON(String sitename, Float pm2_5, Float pm10, Float so2, Float no2,
			Float co, Float o3, Float aqi, Integer time, Float[] coordinates) {
		// private String sitename;
		// private Float pm2_5;
		// private Float pm10;
		// private Float so2;
		// private Float no2;
		// private Float co;
		// private Float o3;
		// private Float aqi;
		// private Integer time;
		PropertiesSitePollutantForecast properties = new PropertiesSitePollutantForecast(sitename, pm2_5, pm10, so2, no2, co, o3, aqi, time);
		// private String type;
		// private Float[] coordinates;
		GeometryPoint geometry = new GeometryPoint(coordinates);

		SitePollutantForecast sc = new SitePollutantForecast(properties, geometry);
		return (JSONObject) JSONObject.toJSON(sc);
	}



}
